<!DOCTYPE html>
<html>

<head>
    <meta name="layout" content="main"/>

    <g:set var="entityName" value="${message(code: 'opportunity.label', default: 'Opportunity')}"/>
    <title>信用贷款（普通页面）-opportunityLayout32</title>
    
</head>

<body>
<input type="hidden" value="${this.opportunity?.id}" id="opportunityId">

<div class="small-header">
    <div class="hpanel">
        <div class="panel-body clearfix">
            <h2 class="font-light pull-left">
                订单号: ${this.opportunity.serialNumber}
            </h2>

            <div id="navbar-example" class="pull-right href-link">
                <ul class="nav navbar-nav" role="tablist">
                    <li class="active"><a class="btn-link page-scroll" href="#first">订单基本信息</a></li>
                    <li><a class="btn-link page-scroll" page-scroll="" href="#second">报单人信息</a></li>
                    <li><a class="btn-link page-scroll" page-scroll="" href="#third">押品信息</a></li>
                    <li><a class="btn-link page-scroll" page-scroll="" href="#fourth">借款人及抵押人信息</a></li>
                    <li><a class="btn-link page-scroll" page-scroll="" href="#fifth">费用</a></li>
                    <li><a class="btn-link page-scroll" page-scroll="" href="#sixth">附件信息</a></li>
                    <li><a class="btn-link page-scroll" page-scroll="" href="#seventh">任务指派</a></li>
                </ul>
            </div>

        </div>
    </div>
</div>

<div class="content active animate-panel">
    <div class="row">
        <g:if test="${flash.message}">
            <div class="message alert alert-info" role="status">${flash.message}
                <button type="button" class="close" data-dismiss="alert" aria-label="Close"><span
                        aria-hidden="true">×</span></button>
            </div>
        </g:if>
        <g:hasErrors bean="${this.opportunityTeam}">
            <ul class="errors" role="alert">
                <g:eachError bean="${this.opportunityTeam}" var="error">
                    <li>
                        <g:if test="${error in org.springframework.validation.FieldError}">data-field-id="${error.field}"</g:if>
                        <g:message error="${error}"/>
                    </li>
                </g:eachError>
            </ul>
        </g:hasErrors>
        <div id="hbreadcrumb" class="pull-left">
            <ol class="hbreadcrumb breadcrumb m-t-none">
                <li>贷款管理系统</li>
                <li>
                    <g:link controller="opportunityTeam" action="index">订单管理</g:link>
                </li>
                <li class="active">
                    <span>信息查看</span>
                </li>
            </ol>
        </div>

        <div class="pull-right">
            <g:if test="${this.currentFlow?.document && this?.currentFlow?.document?.active}">
                <input type="hidden" value="${this?.currentFlow?.document?.document}" id="document">
                <button class="btn btn-success btn-xs" data-toggle="modal" data-target="#myModaDocument">帮助文档</button>
            </g:if>
            <g:else>
                <button class="btn btn-default btn-xs" disabled="disabled">帮助文档</button>
            </g:else>
        </div>

    </div>

    <div class="row" id="first">
        <div class="hpanel hred contact-panel">
            <div class="panel-heading">
                <div class="panel-tools">
                    <sec:ifNotGranted roles="ROLE_COO">
                        %{--<g:link class="btn btn-info btn-xs" controller="workflowInstance"
                                params="[opportunity: this.opportunity?.id]"
                                action="index"></i>查看工作流2.0</g:link>
                        <g:link class="btn btn-info btn-xs" controller="workflowInstance"
                                params="[opportunity: this.opportunity?.id]"
                                action="create"><i class="fa fa-plus"></i>新增工作流2.0</g:link>--}%
                        <g:link class="btn btn-info btn-xs" controller="opportunity" id="${this.opportunity?.id}"
                                action="edit"><i class="fa fa-edit"></i>编辑</g:link>
                    </sec:ifNotGranted>
                </div>
                订单基本信息
            </div>

            <div class="panel-body">
                <h4>
                    ${this.opportunity.serialNumber}
                    (<g:if test="${this.opportunity?.type}">${this.opportunity?.type?.name}</g:if>
                    <g:else>${com.next.OpportunityType.findByCode('10')?.name}</g:else>)
                    <g:if test="${this.opportunity?.isTest}">
                        <span class="label label-danger pull-right"><i class="fa fa-star"></i> 测试 <i
                                class="fa fa-star"></i>
                        </span>
                    </g:if>
                </h4>

                <div class="col-md-1">
                    <strong>
                        <span class="glyphicon glyphicon-user"
                              aria-hidden="true"></span> <span class="nameFormat">${this.opportunity?.fullName}</span>
                    </strong>
                </div>
                <g:if test="${this.opportunity?.protectionEndTime > new Date()}">
                    <div class="col-md-1">
                        <span class="fa fa-chain"></span>${this.opportunity?.protectionEndTime - this.opportunity?.protectionStartTime}天
                    </div>
                </g:if>

                <div class="col-md-2">
                    <strong>${this.opportunity?.stage?.description}</strong>
                </div>

                <div class="col-md-2">
                    <strong>抵押凭证类型：${this.opportunity?.mortgageCertificateType?.name}</strong>
                </div>
                <g:if test="${com.next.Attachments.findByOpportunityAndType(this.opportunity, com.next.AttachmentType.findByName('普通签呈'))}">
                    <div class="col-md-2">
                        <strong>
                            签呈类型：普通签呈
                        </strong>
                    </div>

                </g:if>
                <g:elseif
                        test="${com.next.Attachments.findByOpportunityAndType(this.opportunity, com.next.AttachmentType.findByName('特批签呈'))}">
                    <div class="col-md-2">
                        <strong>
                            签呈类型：特批签呈
                        </strong>
                    </div>
                </g:elseif>
                <div class="col-md-1">
                    <strong>是否合规检查：<g:if test="${this.opportunity?.complianceChecking == true}">是</g:if>
                        <g:if test="${this.opportunity?.complianceChecking == false}">否</g:if></strong>
                </div>

                <g:if test="${this.opportunity?.jqStatus != null && this.opportunity?.jqStatus == '手动结清'}">
                    <div class="col-md-2">
                        <strong>结清状态：${this.opportunity?.jqStatus}</strong>
                    </div>
                </g:if>

                <g:if test="${this.opportunity?.importDate}">
                    <div class="col-md-2">
                        <strong>导入时间：<g:formatDate format="yyyy-MM-dd HH:mm:ss "
                                                   date="${this.opportunity?.importDate}"/></strong>
                    </div>
                </g:if>
                <g:if test="${this.opportunity?.externalModifiedDate}">
                    <div class="col-md-2">
                        <strong>外部修改时间：<g:formatDate format="yyyy-MM-dd HH:mm:ss "
                                                     date="${this.opportunity?.externalModifiedDate}"/></strong>
                    </div>
                </g:if>

                <g:if test="${this.opportunity?.status == 'Failed'}"><span
                        class="label label-danger pull-right">订单结果：失败</span></g:if>
                <g:elseif test="${this.opportunity?.status == 'Completed'}"><span
                        class="label label-success pull-right">订单结果：成功</span></g:elseif>
                <g:else><span class="label label-info pull-right">订单结果：进行中</span></g:else>
            </div>

            <div class="panel-footer contact-footer">
                <div class="row">
                    <div class="col-md-1 border-right">
                        <div class="contact-stat">
                            <span>拟贷款期限</span>
                            <strong>${this.opportunity?.loanDuration}月</strong>
                        </div>
                    </div>

                    <div class="col-md-1 border-right">
                        <div class="contact-stat">
                            <span>实际贷款期限</span>
                            <strong>${this.opportunity?.actualLoanDuration}月</strong>
                        </div>
                    </div>

                    <div class="col-md-2 border-right">
                        <div class="contact-stat">
                            <span>申请金额</span>
                            <strong><g:formatNumber number="${this.opportunity?.loanAmount}" minFractionDigits="2"
                                                    maxFractionDigits="2"/>元</strong>
                        </div>
                    </div>

                    <div class="col-md-1 border-right">
                        <div class="contact-stat">
                            <span>初审</span>
                            <strong>${this.opportunity?.lender?.level?.description}</strong>
                        </div>
                    </div>

                    <div class="col-md-4 border-right">
                        <div class="contact-stat">
                            <span>审核可贷金额</span>
                            <strong><g:formatNumber number="${this.opportunity?.actualAmountOfCredit}" minFractionDigits="2" maxFractionDigits="2" format="###,###.##"/>元；${this.opportunity?.interestPaymentMethod?.name}；
                            <g:if test="${this.opportunity?.interestPaymentMethod?.name == '上扣息'}">
                                上扣息月份数:${this.opportunity?.monthOfAdvancePaymentOfInterest}个月；
                            </g:if>
                            <!-- 借款服务费<g:formatNumber
                                    number="${this.opportunity?.serviceCharge}"
                                    maxFractionDigits="9"/>% -->
                            渠道服务费<g:formatNumber
                                    number="${this.opportunity?.commissionRate}"
                                    maxFractionDigits="9"/>%；${this.opportunity?.commissionPaymentMethod}；
                            <!-- 实际月息<g:formatNumber number="${this.opportunity?.monthlyInterest}"
                                                     maxFractionDigits="9"/>% -->

                            </strong>
                        </div>
                    </div>

                    <div class="col-md-1 border-right">
                        <div class="contact-stat">
                            <span>产品类型:</span>
                            <strong>${this.opportunity?.product?.name}</strong>
                        </div>
                    </div>


                    <div class="col-md-1 border-right">
                        <div class="contact-stat">
                            <span>一抵金额</span>
                            <strong><g:formatNumber number="${this.opportunity?.firstMortgageAmount}" minFractionDigits="2" maxFractionDigits="2" format="###,###.##"/>元</strong>
                        </div>
                    </div>

                    <div class="col-md-1">
                        <div class="contact-stat">
                            <span>二抵金额</span>
                            <strong><g:formatNumber number="${this.opportunity?.secondMortgageAmount}" minFractionDigits="2" maxFractionDigits="2" format="###,###.##"/>元</strong>
                        </div>
                    </div>

                </div>
            </div>
        </div>
    </div>

    <div class="row" id="second">
        <div class="hpanel hred">
            <div class="panel-heading">
                <div class="panel-tools">
                    <a class="showhide"><i class="fa fa-chevron-up"></i></a>
                </div>
                报单人信息
            </div>

            <div class="panel-body">
                <div class="row">
                    <div class="col-md-2 border-right">
                        <div class="contact-stat">
                            <span>姓名</span>
                            <strong>
                                <span class="nameFormat">${this.opportunity?.contact?.fullName}</span>
                            </strong>
                        </div>
                    </div>

                    <div class="col-md-2 border-right">
                        <div class="contact-stat">
                            <span>手机号</span>
                            <strong class="cellphoneFormat">${this.opportunity?.contact?.cellphone}</strong>
                        </div>
                    </div>

                    <div class="col-md-2 border-right">
                        <div class="contact-stat">
                            <span>所属公司</span>
                            <strong>${this.opportunity?.contact?.account?.name}</strong>
                        </div>
                    </div>

                    <div class="col-md-2 border-right">
                        <div class="contact-stat">
                            <span>销售姓名</span>
                            <strong><span class="nameFormat">${this.opportunity?.user?.fullName}</span></strong>
                        </div>
                    </div>

                    <div class="col-md-2 border-right">
                        <div class="contact-stat">
                            <span>销售组别</span>
                            <strong>${this.opportunity?.user?.account?.name}</strong>
                        </div>
                    </div>

                    <div class="col-md-2">
                        <div class="contact-stat">
                            <span>外部唯一ID</span>
                            <strong>${this.opportunity?.contact?.externalId}</strong>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <g:each in="${this.opportunityFlexFieldCategorys}">
        <g:if test="${(it?.flexFieldCategory?.name =='消费分期')}">

            <div class="row" id="">
                <div class="hpanel hyellow">
                    <div class="panel-heading hbuilt">
                        <div class="panel-tools">
                          <g:each in="${this.opportunityFlexFieldCategorys}">
                              <g:if test="${it?.flexFieldCategory?.name == '消费分期'}">
                                  <g:link class="btn btn-info btn-xs" controller="opportunityFlexField" action="batchEdit"
                                          id="${it?.id}"><i class="fa fa-edit"></i>编辑</g:link>
                              </g:if>
                          </g:each>

                          <a class="showhide"><i class="fa fa-chevron-up"></i></a>
                        </div>
                        ${it?.flexFieldCategory?.name}
                    </div>

                    <div class="panel-body no-padding">
                        <div class="table-responsive">
                        <table class="table table-striped table-bordered table-hover text-center">
                            <thead>
                            <tr>
                            <th>商品名称</th>
                            <th>交易日期</th>
                            <th>订单金额</th>
                            <th>订单编号</th>
                            <th>分期金额</th>
                            <th>分期月数</th>
                            <th>每期还款额</th>
                            </tr>
                            </thead>
                            <tbody>

                                <tr>
                                    <td>
                                    <g:each in="${it?.fields}" var="field">
                                    <g:if test="${field?.name == '商品名称'}">
                                      ${field?.value}
                                    </g:if>
                                    </g:each>
                                    </td>
                                    <td>
                                    <g:each in="${it?.fields}" var="field">
                                    <g:if test="${field?.name == '交易日期'}">
                                      ${field?.value}
                                    </g:if>
                                    </g:each>
                                    </td>
                                    <td>
                                    <g:each in="${it?.fields}" var="field">
                                    <g:if test="${field?.name == '订单金额'}">
                                      ${field?.value}
                                    </g:if>
                                    </g:each>
                                    </td>
                                    <td>
                                    <g:each in="${it?.fields}" var="field">
                                    <g:if test="${field?.name == '订单编号'}">
                                      ${field?.value}
                                    </g:if>
                                    </g:each>
                                    </td>
                                    <td>
                                    <g:each in="${it?.fields}" var="field">
                                    <g:if test="${field?.name == '分期金额'}">
                                      ${field?.value}
                                    </g:if>
                                    </g:each>
                                    </td>
                                    <td>
                                    <g:each in="${it?.fields}" var="field">
                                    <g:if test="${field?.name == '分期月数'}">
                                      ${field?.value}
                                    </g:if>
                                    </g:each>
                                    </td>
                                    <td>
                                    <g:each in="${it?.fields}" var="field">
                                    <g:if test="${field?.name == '每期还款额'}">
                                      ${field?.value}
                                    </g:if>
                                    </g:each>
                                    </td>

                                </tr>

                            </tbody>
                        </table>
                        </div>
                    </div>
                </div>
            </div>
        </g:if>
    </g:each>


    <div class="row" id="fourth">
        <div class="hpanel hgreen">
            <div class="panel-heading">
                <div class="panel-tools">
                  <g:link class="btn btn-info btn-xs" controller="ruleEngineProvider"
                          action="evaluate" id="${this.opportunity.id}"><i
                          class="fa fa-database"></i>决策引擎</g:link>
                        <g:if test="${this.opportunity.contacts?.size() > 0}">
                            <g:link target=" _blank" class="btn btn-info btn-xs" controller="creditReportConstraint"
                                    action="creditReportShow" id="${this.opportunity.id}"><i
                                    class="fa fa-database"></i>大数据</g:link>
                        </g:if>

                            <g:link class="btn btn-info btn-xs" controller="opportunityContact" action="create"
                                    params="[opportunity: this.opportunity.id]"><i class="fa fa-plus"></i>新增</g:link>

                    <a class="showhide"><i class="fa fa-chevron-up"></i></a>
                </div>
                借款人及抵押人信息
            </div>

            <div class="panel-body no-padding">
                <div class="table-responsive">
                    <table class="table table-striped table-bordered table-hover text-center">
                        <thead>
                        <tr>
                            <g:sortableColumn property="type" title="联系人"></g:sortableColumn>
                            <g:sortableColumn property="fullName" title="姓名"></g:sortableColumn>
                            <g:sortableColumn property="idNumber" title="身份证号"></g:sortableColumn>
                            <g:sortableColumn property="cellphone" title="手机号"></g:sortableColumn>
                            <g:sortableColumn property="maritalStatus" title="婚否"></g:sortableColumn>
                            <g:sortableColumn property="age" title="年龄(岁)"></g:sortableColumn>
                            <g:sortableColumn property="profession" title="职业"></g:sortableColumn>
                            <g:sortableColumn property="country" title="国籍"></g:sortableColumn>
                            <g:sortableColumn property="identityType" title="身份证件类型"></g:sortableColumn>
                            <g:sortableColumn property="monthlyIncome" title="月收入（元）"></g:sortableColumn>
                            <g:sortableColumn property="connectedType" title="新客户"></g:sortableColumn>
                            <g:sortableColumn property="isBlackList" title="反欺诈结果"></g:sortableColumn>
                            <g:sortableColumn property="level" title="是否VIP"></g:sortableColumn>

                                    <g:sortableColumn width="8%" class="text-center" property="operation" colspan="2"
                                                      title="操作"></g:sortableColumn>
                        </tr>
                        </thead>
                        <tbody>
                        <g:each in="${this.opportunityContacts}">
                            <tr>
                                <td>
                                    <sec:ifNotGranted roles="ROLE_COO">
                                        <g:link controller="opportunityContact" action="show"
                                                id="${it?.id}">${it?.type?.name}</g:link>
                                    </sec:ifNotGranted>
                                    <sec:ifAllGranted roles="ROLE_COO">
                                        ${it?.type?.name}
                                    </sec:ifAllGranted>
                                </td>
                                <td>
                                    <span class="nameFormat">${it?.contact?.fullName}</span>
                                </td>
                                <td  class="certificateFormat">
                                    ${it?.contact?.idNumber}
                                </td>
                                <td class="cellphoneFormat">
                                    ${it?.contact?.cellphone}
                                </td>
                                <td>
                                    ${it?.contact?.maritalStatus}
                                </td>
                                <td>
                                    <g:if test="${it?.contact?.idNumber}">
                                        ${new Date().format("yyyy").toInteger().minus(it?.contact?.idNumber[6..9].toInteger())}
                                    </g:if>
                                    <g:else>
                                        ${it?.contact?.idNumber}
                                    </g:else>
                                </td>
                                <td>
                                    ${it?.contact?.profession?.name}
                                </td>
                                <td>
                                    ${it?.contact?.country?.name}
                                </td>
                                <td>
                                    ${it?.contact?.identityType?.name}
                                </td>
                                <td>
                                    ${it?.contact?.monthlyIncome}
                                </td>
                                <td>
                                  <g:if test="${it?.contact?.clientType == 'new'}">是</g:if><g:else>否</g:else>
                                </td>
                                <td><g:if test="${it?.contact?.isBlackList}">命中</g:if><g:else>未命中</g:else></td>
                                <td><g:if test="${it?.contact?.level?.name=='A'}">是</g:if><g:else>否</g:else></td>
                                    <td class="text-center">
                                      <g:link class="btn btn-primary btn-outline btn-xs" controller="opportunityContact" action="show"
                                              id="${it?.id}">央行征信</g:link>

                                    </td>

                                        <td class="text-center">
                                            <g:form resource="${it}" method="DELETE">
                                                <button class="deleteBtn btn btn-danger btn-xs btn-outline" type="button"><i
                                                        class="fa fa-trash-o"></i> 删除</button>
                                            </g:form>
                                        </td>

                            </tr>
                        </g:each>
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
    </div>

    <g:each in="${this.opportunityFlexFieldCategorys}">
        <g:if test="${(it?.flexFieldCategory?.name =='决策引擎结果')}">

            <div class="row" id="">
                <div class="hpanel hyellow">
                    <div class="panel-heading hbuilt">
                        <div class="panel-tools">

                        </div>
                        ${it?.flexFieldCategory?.name}
                    </div>

                    <div class="panel-body no-padding">
                        <div class="table-responsive">
                        <table class="table table-striped table-bordered table-hover text-center">
                            <thead>
                            <tr>
                            <th>策略名</th>
                            <th>决策场景</th>
                            <th>风险阈值</th>
                            <th>评级</th>
                            <th>申请额度（元）</th>
                            <th>评分结果</th>
                            <th>债务收入比</th>
                            <th>还款期限</th>

                            </tr>
                            </thead>
                            <tbody>

                                <tr>
                                    <td>
                                    <g:each in="${it?.fields}" var="field">
                                    <g:if test="${field?.name == 'ProcessCode'}">
                                      ${field?.value}
                                    </g:if>
                                    </g:each>
                                    </td>
                                    <td>
                                    <g:each in="${it?.fields}" var="field">
                                    <g:if test="${field?.name == 'Decision'}">
                                      ${field?.value}
                                    </g:if>
                                    </g:each>
                                    </td>
                                    <td>
                                    <g:each in="${it?.fields}" var="field">
                                    <g:if test="${field?.name == 'RiskArea'}">
                                      ${field?.value}
                                    </g:if>
                                    </g:each>
                                    </td>
                                    <td>
                                    <g:each in="${it?.fields}" var="field">
                                    <g:if test="${field?.name == 'Rating'}">
                                      ${field?.value}
                                    </g:if>
                                    </g:each>
                                    </td>
                                    <td>
                                    <g:each in="${it?.fields}" var="field">
                                    <g:if test="${field?.name == 'RequestedAmount'}">
                                      ${field?.value}
                                    </g:if>
                                    </g:each>
                                    </td>
                                    <td>
                                    <g:each in="${it?.fields}" var="field">
                                    <g:if test="${field?.name == 'StructScoreRawScore'}">
                                      ${field?.value}
                                    </g:if>
                                    </g:each>
                                    </td>
                                    <td>
                                    <g:each in="${it?.fields}" var="field">
                                    <g:if test="${field?.name == 'DTI'}">
                                      ${field?.value}
                                    </g:if>
                                    </g:each>
                                    </td>
                                    <td>
                                    <g:each in="${it?.fields}" var="field">
                                    <g:if test="${field?.name == 'Term'}">
                                      ${field?.value}
                                    </g:if>
                                    </g:each>
                                    </td>

                                </tr>

                            </tbody>
                        </table>
                        </div>
                    </div>
                </div>
            </div>
        </g:if>
    </g:each>

    <g:render template="/layouts/opportunityTemplate/opportunityProductTemplate"/>
    <g:render template="/layouts/opportunityTemplate/billsItemsTemplate"/>


    <g:render template="/layouts/opportunityTemplate/bankAccountsTemplate"/>
    <g:render template="/layouts/opportunityTemplate/opportunityContractsTemplate"/>
    <g:render template="/layouts/opportunityTemplate/transactionRecordsTemplate"/>
    <footer class="footer">


            <g:render template="/layouts/opportunityTemplate/footerRightTemplate"/>

    </footer>
<script>
    $(function () {
        $("body").addClass("fixed-small-header");
    });

</script>
</body>

</html>
